// 训练相关 API 接口
import api from './api'
import responseHandler from '@/utils/responseHandler'

/**
 * 开始训练
 * @param {Object} request - 开始训练请求参数
 * @returns {Promise<Object>} 训练会话信息
 */
export async function startTraining(request) {
  const response = await api.post('/training/start', request)
  return responseHandler.handleResponse(response)
}

/**
 * 回答问题
 * @param {Object} request - 回答问题请求参数
 * @returns {Promise<Object>} 回答结果
 */
export async function answerQuestion(request) {
  const response = await api.post('/training/answer', request)
  return responseHandler.handleResponse(response)
}

/**
 * 结束训练
 * @param {string} sessionId - 会话ID
 * @returns {Promise<Object>} 训练结果
 */
export async function finishTraining(sessionId) {
  const response = await api.post('/training/finish', { sessionId })
  return responseHandler.handleResponse(response)
}

/**
 * 获取可用题型列表
 * @returns {Promise<Array>} 题型列表
 */
export async function getQuestionTypes() {
  const response = await api.get('/training/question-types')
  return responseHandler.handleResponse(response)
}

export default {
  startTraining,
  answerQuestion,
  finishTraining,
  getQuestionTypes
}